#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * DNS Service Record Structure
 *      epresents a DNS service (SRV) record.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"
using namespace System;
using namespace System::Net;

namespace Adaptive
{
	namespace Network
	{
		namespace Dns
		{
			/// <summary>
			/// Represents a DNS service (SRV) record.
			/// </summary>
			public value struct DnsServiceRecord
			{
			internal:
				/// <summary>
				/// Initializes a new instance of the class from the unmanaged record.
				/// </summary>
				/// <param name="record"> A pointer to a DNS_RECORD structure whose contents are to be copied.</param>
				DnsServiceRecord(DNS_RECORD* record)
				{
					if ((record == NULL) || (record->wType != DNS_TYPE_SRV))
					{
						TargetName = String::Empty;
						PriorityValue = 0;
						Weight = 0;
						Port = 0;
					}
					else
					{
						TargetName = gcnew String ( record->Data.SRV.pNameTarget );
						PriorityValue = record->Data.SRV.wPriority;
						Weight = record->Data.SRV.wWeight;
						Port = record->Data.SRV.wPort;
					}
				}
			private:
				/// <summary>
				/// Static constructor.
				/// </summary>
				static DnsServiceRecord()
				{
				}

			public:

				/// <summary>
				/// A string representing the target host.
				/// </summary>
				/// <value>
				/// A host name value or an empty string.
				/// </value>
				String^		TargetName;
				/// <summary>
				/// Priority of the target host specified in the owner name. Lower numbers imply higher priority.
				/// </summary>
				/// <value>
				/// Priority value.
				/// </value>
				short		PriorityValue;
				/// <summary>
				/// Weight of the target host. Useful when selecting among hosts with the same priority. The chances of using this 
				/// host should be proportional to its weight.
				/// </summary>
				/// <value>
				/// Weighted value.
				/// </value>
				short		Weight;
				/// <summary>
				/// Port used on the target host for the service.
				/// </summary>
				/// <value>
				/// An Internet port number in the range 1 - 65536.
				/// </value>
				short		Port;

			};
		}
	}
}